﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using PccCommonForC;


/// <summary>
/// Summary description for clsWebShop
/// </summary>
public class clsWebShop
{
    SqlConnection Conn;
    public clsWebShop()
    {
        //string strCon = @"Data Source=NICKEL\SQLEXPRESS;Initial Catalog=WebShop;User ID=sa; Pwd=pyvweb;Max Pool Size=30;Min Pool Size=0;Pooling = true";

        //string strCon = @"Data Source=.;Initial Catalog=WebShop;User ID=sa; Pwd=pyvweb;Max Pool Size=30;Min Pool Size=0;Pooling = true";
        string strCon = "Data Source=" + System.Configuration.ConfigurationManager.AppSettings["AppConnectionServer"] + ";Initial Catalog=" + System.Configuration.ConfigurationManager.AppSettings["AppConnectionDB"] + ";User ID=" + System.Configuration.ConfigurationManager.AppSettings["AppConnectionUser"] + ";Pwd=" + System.Configuration.ConfigurationManager.AppSettings["AppConnectionPwd"] + ";Max Pool Size=30;Min Pool Size=0;Pooling = true";
        Conn = new SqlConnection(strCon);
        Conn.Open();
    }

    public DataSet GetData(string strSQL)
    {
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();
        SqlDataAdapter adap = new SqlDataAdapter(strSQL, Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public string UpdateData(string strSQL)
    {
        int iReturn = 0;
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();
        SqlCommand cmd = new SqlCommand(strSQL, Conn);
        iReturn = cmd.ExecuteNonQuery();
        Conn.Close();
        return iReturn.ToString();
    }

    public string UpdateViewCount(string PDID)
    {
        int iReturn = 0;
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();
        SqlCommand cmd = new SqlCommand("update product set ViewCount=isnull(ViewCount,0)+1 where PDID='" + killSQLInjection(PDID) + "'", Conn);
        iReturn = cmd.ExecuteNonQuery();
        Conn.Close();
        return iReturn.ToString();
    }
    public string UpdateViewCountFilm(string PDID)
    {
        int iReturn = 0;
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();
        SqlCommand cmd = new SqlCommand("update Film set ViewCount=isnull(ViewCount,0)+1 where FilmID='" + killSQLInjection(PDID) + "'", Conn);
        iReturn = cmd.ExecuteNonQuery();
        Conn.Close();
        return iReturn.ToString();
    }


    #region "None Pro"

    public bool IsShowSignAutNoneProc(string UserID)
    {
        bool f = false;
        try
        {
            if (Conn.State == ConnectionState.Closed)
                Conn.Open();
            SqlCommand cmd = new SqlCommand("select Sign_mk from shr_AutUser where UserID=" + UserID + "", Conn);
            string Sign_mk = cmd.ExecuteScalar().ToString();
            if (Sign_mk == "Y")
                f = true;
        }
        catch { }
        Conn.Close();
        return f;
    }
    public bool IsShowPrintAutNoneProc(string UserID)
    {
        bool f = false;
        try
        {
            if (Conn.State == ConnectionState.Closed)
                Conn.Open();
            SqlCommand cmd = new SqlCommand("select Print_mk from shr_AutUser where UserID=" + UserID + "", Conn);
            string Sign_mk = cmd.ExecuteScalar().ToString();
            if (Sign_mk == "Y")
                f = true;
        }
        catch { }
        Conn.Close();
        return f;
    }
    public bool IsShowReviewAutNoneProc(string UserID)
    {
        bool f = false;
        try
        {
            if (Conn.State == ConnectionState.Closed)
                Conn.Open();
            SqlCommand cmd = new SqlCommand("select Review_mk from shr_AutUser where UserID=" + UserID + "", Conn);
            string Sign_mk = cmd.ExecuteScalar().ToString();
            if (Sign_mk == "Y")
                f = true;
        }
        catch { }
        Conn.Close();
        return f;
    }

    public decimal GetMoney(string KindMoney)
    {
        decimal dMoney = 0;
        try
        {
            if (Conn.State == ConnectionState.Closed)
                Conn.Open();

            string strSQL = "Select top 1 " + KindMoney + " From Rate  Order by RateDate Desc";
            SqlCommand cmd = new SqlCommand(strSQL, Conn);
            dMoney = (decimal)cmd.ExecuteScalar();
        }
        catch { }
        Conn.Close();
        return dMoney;
    }
    public string Get_CountStorerByCondition(string StID)
    {

        string counts = "0";
        try
        {
            if (Conn.State == ConnectionState.Closed)
                Conn.Open();


            string strSQL = "SELECT count(*)countst  FROM [Product]   where 1=1 ";

            if (StID != "0")
            {
                strSQL += " and stid='" + StID + "'";
            }

            SqlCommand cmd = new SqlCommand(strSQL, Conn);
            counts = cmd.ExecuteScalar().ToString();
        }
        catch { }
        Conn.Close();
        return counts;
    }

    public string Get_QuantityStoreByCondition(string PDID, string StID)
    {

        string counts = "0";
        try
        {
            if (Conn.State == ConnectionState.Closed)
                Conn.Open();


            string strSQL = "SELECT isnull(sum(Input),)-isnull(sum(Output),0)Quantity_Store  FROM [Store_Product] Where 1=1 ";

            if (PDID != "")
            {
                strSQL += " and PDID='" + PDID + "'";
            }
            if (StID != "0")
            {
                strSQL += " and StID='" + StID + "'";
            }

            SqlCommand cmd = new SqlCommand(strSQL, Conn);
            counts = cmd.ExecuteScalar().ToString();
        }
        catch { }
        Conn.Close();
        return counts;
    }

    public DataSet Get_QuantityStoreGroup(string PDID, string StID)
    {

        string counts = "0";

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();


        string strSQL = "SELECT PDID,isnull(sum(Input),0)-isnull(sum(Output),0)Quantity_Store  FROM [Store_Product]  Where 1=1 ";

        if (PDID != "")
        {
            strSQL += " and PDID='" + PDID + "'";
        }
        if (StID != "0")
        {
            strSQL += " and StID='" + StID + "'";
        }

        strSQL += "  Group By PDID Having  isnull(sum(Input),0)-isnull(sum(Output),0)>0";
        SqlDataAdapter adap = new SqlDataAdapter(strSQL, Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }

    public string Get_CountStorerByPDIDCondition(string StID, string PDID)
    {

        string counts = "0";
        try
        {
            if (Conn.State == ConnectionState.Closed)
                Conn.Open();


            string strSQL = "SELECT  isnull(sum([Input]),0)-isnull(sum([Output]),0) countst  FROM [Store_Product]   where 1=1 ";

            if (StID != "0")
            {
                strSQL += " and stid='" + StID + "'";
            }
            if (PDID != "")
            {
                strSQL += " and PDID='" + PDID + "'";
            }

            SqlCommand cmd = new SqlCommand(strSQL, Conn);
            counts = cmd.ExecuteScalar().ToString();
        }
        catch { }
        Conn.Close();
        return counts;
    }

    public DataSet Get_QuantityStoreByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);
        string PdID = msg.Query("PdID");
        string StID = msg.Query("StID");


        string strSQL = "select isnull(sum([Input]),0)-isnull(sum([Output]),0) Total from Store_Product where 1=1  ";


        if (PdID.Length != 0)
        {
            strSQL += " and PdID='" + PdID + "'";
        }
        if (StID.Length != 0)
        {
            strSQL += " and StID='" + StID + "'";
        }
        SqlDataAdapter adap = new SqlDataAdapter(strSQL, Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }

    public DataSet Get_pd_PropertyDetailByCondition_NonePro(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);
        string PdID = msg.Query("PDID");
        string CatID = msg.Query("CatID");
        string Type = msg.Query("Type");


        string strSQL = "SELECT [PrtNm], [PrtdDesc] FROM [pd_PropertyDetail] pp inner join [cat_Properties] cp  on cp.PrtID=pp.PrtID  where pp.PDID='" + PdID + "'  ";

        if (Type == "1")
            strSQL += " and (prtNm=N'Mã số' or prtNm='STT')";


        if (CatID.Length > 0 && CatID != "0")
        {
            strSQL += "  and cp.catid=" + CatID + "";
        }
        SqlDataAdapter adap = new SqlDataAdapter(strSQL, Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }


    public DataSet Get_BannerByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);
        string ID = msg.Query("ID");
        string NavigateUrl = msg.Query("NavigateUrl");
        string ShowMK = msg.Query("ShowMK");

        string strSQL = "select * from Banner where 1=1 ";

        if (ID.Length != 0)
        {
            strSQL += " and ID='" + killSQLInjection(ID) + "'";
        }
        if (NavigateUrl.Length != 0)
        {
            strSQL += " and NavigateUrl='" + killSQLInjection(NavigateUrl) + "'";
        }
        if (ShowMK.Length != 0)
        {
            strSQL += " and ShowMK='" + killSQLInjection(ShowMK) + "'";
        }

        strSQL += " order by UpdDate desc";

        SqlDataAdapter adap = new SqlDataAdapter(strSQL, Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_StoreByKindNoNoneProc()
    {
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();
        SqlDataAdapter adap = new SqlDataAdapter("select * from Store where Status<>'D' Order by StName", Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_ContactByKindNoNoneProc(string KindNo)
    {
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();
        SqlDataAdapter adap = new SqlDataAdapter("select top 1 * from Contact where KindNo='" + KindNo + "'", Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_shr_AuthorityByStatusNoneProc(string Status)
    {
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();
        SqlDataAdapter adap = new SqlDataAdapter("select * from shr_Authority where Status='" + Status + "'", Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_TopicNoneProc()
    {
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();
        SqlDataAdapter adap = new SqlDataAdapter("select * from Topic where Status<>'D' order by TopicName", Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_shr_AuthorityNoneProc()
    {
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();
        SqlDataAdapter adap = new SqlDataAdapter("select * from shr_Authority order by AutNm", Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }

    public DataSet Get_CatalogueByTopicIDNoneProc(string TopicID)
    {
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        string strSQL = "Select * From Catalogue  cat	inner join Topic tp on tp.TopicID=cat.TopicID where  cat.Status <>'D' and cat.KindNo='P'";

        if (TopicID != "0")
            strSQL += "  and cat.TopicID=" + TopicID;

        strSQL += " order by cat.CatName";

        SqlDataAdapter adap = new SqlDataAdapter(strSQL, Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }

    public DataSet Get_CatalogueFilmByTopicIDNoneProc(string TopicID)
    {
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        string strSQL = "Select * From Catalogue  cat	inner join Topic tp on tp.TopicID=cat.TopicID where  cat.Status <>'D'   and cat.KindNo='F'";

        if (TopicID != "0")
            strSQL += "  and cat.TopicID=" + TopicID;

        strSQL += " order by cat.CatName";

        SqlDataAdapter adap = new SqlDataAdapter(strSQL, Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }

    public DataSet Get_CatalogByKindNo(string KindNo)
    {
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        string strSQL = "Select * From Catalogue  cat	where  cat.Status <>'D' and ShowMK='Y'";

        if (KindNo != "")
            strSQL += "  and cat.KindNo='" + KindNo + "'";

        strSQL += " order by cat.CatName";

        SqlDataAdapter adap = new SqlDataAdapter(strSQL, Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }


    public DataSet Get_UserByUserIDNoneProc(string UserID)
    {
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        string strSQL = "select * from shr_User suser inner join shr_Authority aut on suser.AutID=aut.AutID  where suser.Status<>'D' and UserID=" + UserID;

        SqlDataAdapter adap = new SqlDataAdapter(strSQL, Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_CustomerByUserIDNoneProc(string UserID)
    {
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        string strSQL = "select * from shr_User suser   where suser.Status<>'D' and UserID=" + UserID;

        SqlDataAdapter adap = new SqlDataAdapter(strSQL, Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }

    public DataSet Get_UserByAutIDNoneProc(string AutID)
    {
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        string strSQL = "select * from shr_User where Status<>'D' and AutID=" + AutID;

        SqlDataAdapter adap = new SqlDataAdapter(strSQL, Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }

    public DataSet Get_Menu_HomeNoneProc()
    {
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        string strSQL = "select * from Menu Where KindNo='H' Order By Seq,MenuName";

        SqlDataAdapter adap = new SqlDataAdapter(strSQL, Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }

    public DataSet Get_MenuNoneProc()
    {
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        string strSQL = "select * from Menu Where KindNo='A' Order By LevelMenuID,Seq,MenuName";

        SqlDataAdapter adap = new SqlDataAdapter(strSQL, Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }

    public DataSet Get_MenuOderMenuNameNoneProc()
    {
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        string strSQL = "select * From Menu Order By LevelMenuID,Seq,MenuName";

        SqlDataAdapter adap = new SqlDataAdapter(strSQL, Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }

    public DataSet Get_GroupMenuOderMenuNameNoneProc()
    {
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        string strSQL = "select * From Menu Where LevelMenuId=0 Order By LevelMenuID,Seq,MenuName";

        SqlDataAdapter adap = new SqlDataAdapter(strSQL, Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_AuthorityOderAuthorityNameNoneProc()
    {
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        string strSQL = "select * From shr_Authority Order By AutNm";

        SqlDataAdapter adap = new SqlDataAdapter(strSQL, Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }

    public DataSet Get_PlaceNoneProc()
    {
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        string strSQL = "select * From Place Order By Seq,PlaceNm";

        SqlDataAdapter adap = new SqlDataAdapter(strSQL, Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }

    public DataSet Get_cat_PropertiesByCatIDNoneProc(string CatID)
    {
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        string strSQL = "select * from cat_Properties where CatID=" + CatID;

        SqlDataAdapter adap = new SqlDataAdapter(strSQL, Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_Top_FilmNoneProc(string top)
    {
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        string strSQL = "select top " + top + " *   From Film  pd inner join Catalogue ctl On ctl.CatID=pd.CatID inner join Topic tp On tp.TopicID=ctl.TopicID Where pd.Status<>'D'  order by pd.Status desc,pd.UpdDate desc";

        SqlDataAdapter adap = new SqlDataAdapter(strSQL, Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_Top_ProductNoneProc(string top)
    {
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        string strSQL = "select top " + top + " *   From Product  pd inner join Catalogue ctl On ctl.CatID=pd.CatID inner join Topic tp On tp.TopicID=ctl.TopicID Where  ctl.KindNo='P' and pd.Status<>'D' order by pd.UpdDate desc";



        SqlDataAdapter adap = new SqlDataAdapter(strSQL, Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_Similar_ProductNoneProc(string top, string exceptPD)
    {
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();


        string strSQL = "select top " + top + "  *   from product pd inner join Catalogue cat on cat.CatID=pd.CatID where pd.Status<>'D' and pd.PdID<>'" + exceptPD + "' and pd.catid=(select catid from product where pdid='" + exceptPD + "') order by pd.ViewCount,pd.UpdDate desc";


        SqlDataAdapter adap = new SqlDataAdapter(strSQL, Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }

    public DataSet Get_Similar_FilmNoneProc(string top, string exceptPD)
    {
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();


        string strSQL = "select top " + top + "  *   from film pd inner join Catalogue cat on cat.CatID=pd.CatID where pd.Status<>'D' and pd.FilmID<>'" + exceptPD + "' and pd.catid=(select catid from FILM where FilmID='" + exceptPD + "') order by pd.ViewCount,pd.UpdDate desc";


        SqlDataAdapter adap = new SqlDataAdapter(strSQL, Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }

    public DataSet GetSaleOfProduct(string top)
    {
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        string strSQL = "select top " + top + " *  From Product  pd inner join Catalogue ctl On ctl.CatID=pd.CatID inner join Topic tp On tp.TopicID=ctl.TopicID Where pd.IsSaleOf='Y' and ctl.KindNo='P' and pd.Status<>'D'";

        strSQL += "  order by pd.UpdDate desc";

        SqlDataAdapter adap = new SqlDataAdapter(strSQL, Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }

    public DataSet Get_Most_ProductNoneProc(string top)
    {
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        string strSQL = "select top " + top + " *  From Product  pd inner join Catalogue ctl On ctl.CatID=pd.CatID inner join Topic tp On tp.TopicID=ctl.TopicID Where pd.Status<>'D' and pd.Is and ctl.KindNo='P' order by pd.ViewCount desc";

        SqlDataAdapter adap = new SqlDataAdapter(strSQL, Conn);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    #endregion

    #region "Get Pro"
    public DataSet Get_OnlineSurportByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_OnlineSurportByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@OnlineID", msg.Query("OnlineID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@OnlineName", msg.Query("OnlineName")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@NickName", msg.Query("NickName")));
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_shr_UserSignByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_shr_UserSignByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@UserID", msg.Query("UserID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@Ext_no", msg.Query("Ext_no")));
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_TypicalProduct(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_TypicalProduct", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@ViewCount", msg.Query("ViewCount")));

        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_ExportListPriceByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        // PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_ExportListPriceByCondition", Conn);

        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }


    public DataSet Get_RssByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_RssByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@RssId", msg.Query("RssId")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@Title", msg.Query("Title")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@Link", msg.Query("Link")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@ShowMK", msg.Query("ShowMK")));

        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_AdsByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_AdsByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@AdsID", msg.Query("AdsID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@AdsNm", msg.Query("AdsNm")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@AdsLink", msg.Query("AdsLink")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@KindNo", msg.Query("KindNo")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@AdsType", msg.Query("AdsType")));

        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }

    public DataSet Get_StoreDetailByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_StoreDetailByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@StID", msg.Query("StID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@StartDate", msg.Query("StartDate")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@EndDate", msg.Query("EndDate")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@DisCompID", msg.Query("DisCompID")));


        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }


    public DataSet Get_shr_AutUserByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_shr_AutUserByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@UserID", msg.Query("UserID")));
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_Product_IMGByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_Product_IMGByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@PDID", msg.Query("PDID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@ImgPD_Desc", msg.Query("ImgPD_Desc")));
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }

    public DataSet Get_DownloadByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_DownloadByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@IdD", msg.Query("IdD")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@TitleD", msg.Query("TitleD")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));

        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_NewsByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_NewsByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@NewsID", msg.Query("NewsID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@Title", msg.Query("Title")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@KindNo", msg.Query("KindNo")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@ViewCount", msg.Query("ViewCount")));

        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_SimilarNewsByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_SimilarNewsByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@NewsID", msg.Query("NewsID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@Title", msg.Query("Title")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@KindNo", msg.Query("KindNo")));

        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_pd_PropertyDetailByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_pd_PropertyDetailByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@PDID", msg.Query("PDID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@PrtID", msg.Query("PrtID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@CatID", msg.Query("CatID")));
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_MenudByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_MenudByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@MenuID", msg.Query("MenuID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@UserID", msg.Query("UserID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@AutID", msg.Query("AutID")));
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_ProductByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_ProductByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@PdName", msg.Query("PdName")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@CatID", msg.Query("CatID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@TopicID", msg.Query("TopicID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@KindNo", msg.Query("KindNo")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@PDID", msg.Query("PDID")));

        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }

    public DataSet Get_FilmByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_FilmByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@PdName", msg.Query("PdName")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@CatID", msg.Query("CatID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@TopicID", msg.Query("TopicID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@KindNo", msg.Query("KindNo")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@PDID", msg.Query("PDID")));

        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_ProductAdminByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_ProductAdminByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@PdName", msg.Query("PdName")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@CatID", msg.Query("CatID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@TopicID", msg.Query("TopicID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@KindNo", msg.Query("KindNo")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@StID", msg.Query("StID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@PDID", msg.Query("PDID")));

        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }


    public DataSet Get_FilmAdminByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_FilmAdminByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@PdName", msg.Query("PdName")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@CatID", msg.Query("CatID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@TopicID", msg.Query("TopicID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@KindNo", msg.Query("KindNo")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@StID", msg.Query("StID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@PDID", msg.Query("PDID")));

        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_ExceptProductByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_ExceptProductByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@PdName", msg.Query("PdName")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@CatID", msg.Query("CatID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@TopicID", msg.Query("TopicID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@StID", msg.Query("StID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@KindNo", msg.Query("KindNo")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@ExceptPD", msg.Query("ExceptPD")));
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_Store_ProductByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_Store_ProductByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;

        adap.SelectCommand.Parameters.Add(new SqlParameter("@StartDate", msg.Query("StartDate")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@EndDate", msg.Query("EndDate")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@PdID", msg.Query("PdID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@StId", msg.Query("StId")));
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }

    public DataSet Get_Store_ProductByConditionInDay(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_Store_ProductByConditionInDay", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@PdID", msg.Query("PdID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@StartDate", msg.Query("StartDate")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@EndDate", msg.Query("EndDate")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@StId", msg.Query("StId")));

        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_StoreMainByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);
        SqlDataAdapter adap = new SqlDataAdapter("Get_StoreMainByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@StartDate", msg.Query("StartDate")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@EndDate", msg.Query("EndDate")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@DisCompID", msg.Query("DisCompID")));

        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_ProductByCondition_Paging(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_ProductByCondition_Paging", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@TopicID", msg.Query("TopicID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@CatID", msg.Query("CatID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@PdName", msg.Query("PdName")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@CatName", msg.Query("CatName")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@TopicName", msg.Query("TopicName")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@IsSaleOf", msg.Query("IsSaleOf")));


        SqlParameter paraOut = new SqlParameter("@Count", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        adap.SelectCommand.Parameters.Add(paraOut);

        DataSet ds = new DataSet();

        if (msg.Query("StartRecord") != "")
        {
            int startRecord = int.Parse(msg.Query("StartRecord"));
            int pageSize = int.Parse(msg.Query("PageSize"));

            adap.Fill(ds, startRecord, pageSize, "ProductList");
            string strOutput = paraOut.Value.ToString();

            DataTable tblCounts = new DataTable("TCounts");
            tblCounts.Columns.Add("Counts", System.Type.GetType("System.String"));
            DataRow dr = tblCounts.NewRow();
            dr["Counts"] = strOutput;
            tblCounts.Rows.Add(dr);
            ds.Tables.Add(tblCounts);
        }
        else
        {
            adap.Fill(ds);
        }
        Conn.Close();
        return ds;
    }

    public DataSet Get_FilmByCondition_Paging(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_FilmByCondition_Paging", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@TopicID", msg.Query("TopicID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@CatID", msg.Query("CatID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@PdName", msg.Query("PdName")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@CatName", msg.Query("CatName")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@TopicName", msg.Query("TopicName")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@IsSaleOf", msg.Query("IsSaleOf")));


        SqlParameter paraOut = new SqlParameter("@Count", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        adap.SelectCommand.Parameters.Add(paraOut);

        DataSet ds = new DataSet();

        if (msg.Query("StartRecord") != "")
        {
            int startRecord = int.Parse(msg.Query("StartRecord"));
            int pageSize = int.Parse(msg.Query("PageSize"));

            adap.Fill(ds, startRecord, pageSize, "ProductList");
            string strOutput = paraOut.Value.ToString();

            DataTable tblCounts = new DataTable("TCounts");
            tblCounts.Columns.Add("Counts", System.Type.GetType("System.String"));
            DataRow dr = tblCounts.NewRow();
            dr["Counts"] = strOutput;
            tblCounts.Rows.Add(dr);
            ds.Tables.Add(tblCounts);
        }
        else
        {
            adap.Fill(ds);
        }
        Conn.Close();
        return ds;
    }
    public DataSet Get_InfLoginCustomerCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_InfLoginCustomerCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@UserNm", msg.Query("UserNm")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@Password", msg.Query("Password")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@SuperAdmin", msg.Query("SuperAdmin")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@SupperPass", msg.Query("SupperPass")));


        SqlParameter paraOut = new SqlParameter("@Exist", SqlDbType.Char, 1);
        paraOut.Direction = ParameterDirection.Output;
        adap.SelectCommand.Parameters.Add(paraOut);

        DataSet ds = new DataSet();
        adap.Fill(ds);

        string strOutput = paraOut.Value.ToString();

        DataTable tblExist = new DataTable("TExist");
        tblExist.Columns.Add("Exist", System.Type.GetType("System.String"));
        DataRow dr = tblExist.NewRow();
        dr["Exist"] = paraOut.Value.ToString();
        tblExist.Rows.Add(dr);
        ds.Tables.Add(tblExist);

        return ds;
    }

    public DataSet Get_Product_CommentByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_Product_CommentByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@PDID", msg.Query("PDID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@CmPD_CusName", msg.Query("CmPD_CusName")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@CmPD_Title", msg.Query("CmPD_Title")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@CmPD_Content", msg.Query("CmPD_Content")));

        DataSet ds = new DataSet();
        adap.Fill(ds);
        return ds;
    }


    public DataSet Get_InfLoginCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_InfLoginCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@UserNm", msg.Query("UserNm")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@Password", msg.Query("Password")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@SuperAdmin", msg.Query("SuperAdmin")));


        SqlParameter paraOut = new SqlParameter("@Exist", SqlDbType.Char, 1);
        paraOut.Direction = ParameterDirection.Output;
        adap.SelectCommand.Parameters.Add(paraOut);

        DataSet ds = new DataSet();
        adap.Fill(ds);

        string strOutput = paraOut.Value.ToString();

        DataTable tblExist = new DataTable("TExist");
        tblExist.Columns.Add("Exist", System.Type.GetType("System.String"));
        DataRow dr = tblExist.NewRow();
        dr["Exist"] = paraOut.Value.ToString();
        tblExist.Rows.Add(dr);
        ds.Tables.Add(tblExist);

        return ds;
    }
    public DataSet Get_Topic_Catalogue(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();
        PccMsg msg = new PccMsg(strXML);
        SqlDataAdapter adap = new SqlDataAdapter("Get_Topic_Catalogue", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@KindNo", msg.Query("KindNo")));
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_TopicByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_TopicByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@TopicName", msg.Query("TopicName")));

        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_MenuByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_MenuByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@MenuName", msg.Query("MenuName")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@LevelMenuID", msg.Query("LevelMenuID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@KindNo", msg.Query("KindNo")));
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_MenuByMenuID(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_MenuByMenuID", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@MenuID", msg.Query("MenuID")));

        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }

    public DataSet Get_FlowOrderHistByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);
        SqlDataAdapter adap = new SqlDataAdapter("Get_FlowOrderHistByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@OrderID", msg.Query("OrderID")));
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }

    public DataSet Get_shr_UserByUserID(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_shr_UserByUserID", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@UserID", msg.Query("UserID")));

        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_CatalogueByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);
        SqlDataAdapter adap = new SqlDataAdapter("Get_CatalogueByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@CatName", msg.Query("CatName")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@TopicID", msg.Query("TopicID")));
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }

    public DataSet Get_DistributionCompanyByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);
        SqlDataAdapter adap = new SqlDataAdapter("Get_DistributionCompanyByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@DisCompID", msg.Query("DisCompID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@Name", msg.Query("Name")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@Phone", msg.Query("Phone")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@Email", msg.Query("Email")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@Address", msg.Query("Address")));
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }

    public DataSet Get_CalOrderDetail(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);
        SqlDataAdapter adap = new SqlDataAdapter("Get_CalOrderDetail", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@Year", msg.Query("Year")));
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }

    public DataSet Get_shr_AuthorityCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);
        SqlDataAdapter adap = new SqlDataAdapter("Get_shr_AuthorityCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@AutNm", msg.Query("AutNm")));
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_shr_UserCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);
        SqlDataAdapter adap = new SqlDataAdapter("Get_shr_UserCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@CusNm", msg.Query("CusNm")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@UserNm", msg.Query("UserNm")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@Email", msg.Query("Email")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@AutID", msg.Query("AutID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@UserID", msg.Query("UserID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@Phone", msg.Query("Phone")));
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_StoreByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);
        SqlDataAdapter adap = new SqlDataAdapter("Get_StoreByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;

        adap.SelectCommand.Parameters.Add(new SqlParameter("@StID", msg.Query("StID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@StName", msg.Query("StName")));
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_shr_CustomerCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);
        SqlDataAdapter adap = new SqlDataAdapter("Get_shr_CustomerCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@CusNm", msg.Query("CusNm")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@UserNm", msg.Query("UserNm")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@Email", msg.Query("Email")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@Phone", msg.Query("Phone")));
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }


    public DataSet Get_RateByCondition(string strXML)
    {
        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);
        SqlDataAdapter adap = new SqlDataAdapter("Get_RateByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@RateID", msg.Query("RateID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@RateDate", msg.Query("RateDate")));
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_shr_UserByUserNm(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);
        SqlDataAdapter adap = new SqlDataAdapter("Get_shr_UserByUserNm", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@UserNm", msg.Query("UserNm")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@ExcUserID", msg.Query("ExcUserID")));
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_shr_UserByUserEmail(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);
        SqlDataAdapter adap = new SqlDataAdapter("Get_shr_UserByUserEmail", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@Email", msg.Query("Email")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@ExcUserID", msg.Query("ExcUserID")));
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_ProductByProductID(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);
        SqlDataAdapter adap = new SqlDataAdapter("Get_ProductByProductID", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@PdID", msg.Query("PdID")));

        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_ProductByPDNm(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);
        SqlDataAdapter adap = new SqlDataAdapter("Get_ProductByPDNm", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@PDName", msg.Query("PDName")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@ExcPDID", msg.Query("ExcPDID")));
        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_OrderPDByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_OrderPDByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@StartDate", msg.Query("StartDate")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@EndDate", msg.Query("EndDate")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@End_MK", msg.Query("End_MK")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@OrderID", msg.Query("OrderID")));



        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }

    public DataSet Get_OrderFilmByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_OrderFilmByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@StartDate", msg.Query("StartDate")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@EndDate", msg.Query("EndDate")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@End_MK", msg.Query("End_MK")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@OrderID", msg.Query("OrderID")));



        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }

    public DataSet Get_OrderPDOverViewByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_OrderPDOverViewByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@StartDate", msg.Query("StartDate")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@EndDate", msg.Query("EndDate")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@End_MK", msg.Query("End_MK")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@OrderID", msg.Query("OrderID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@UserID", msg.Query("UserID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@CusNm", msg.Query("CusNm")));



        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }
    public DataSet Get_OrderRevenueByCondition(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlDataAdapter adap = new SqlDataAdapter("Get_OrderRevenueByCondition", Conn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.Add(new SqlParameter("@StartDate", msg.Query("StartDate")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@EndDate", msg.Query("EndDate")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@OrderID", msg.Query("OrderID")));
        adap.SelectCommand.Parameters.Add(new SqlParameter("@CusNm", msg.Query("CusNm")));



        DataSet ds = new DataSet();
        adap.Fill(ds);
        Conn.Close();
        return ds;
    }

    #endregion

    #region "Ins"

    public string ImportPD(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();
        PccMsg msg = new PccMsg(strXML);

        SqlCommand cmd = new SqlCommand("ImportPD", Conn);
        cmd.CommandType = CommandType.StoredProcedure;


        cmd.Parameters.Add(new SqlParameter("@PdName", msg.Query("PdName")));
        cmd.Parameters.Add(new SqlParameter("@CatID", msg.Query("CatID")));
        cmd.Parameters.Add(new SqlParameter("@Price", msg.Query("Price")));
        cmd.Parameters.Add(new SqlParameter("@Warranty", msg.Query("Warranty")));
        cmd.Parameters.Add(new SqlParameter("@Descript", msg.Query("Descript")));
        cmd.Parameters.Add(new SqlParameter("@ImgURL", msg.Query("ImgURL")));
        cmd.Parameters.Add(new SqlParameter("@Unit", msg.Query("Unit")));
        cmd.Parameters.Add(new SqlParameter("@Capacity", msg.Query("Capacity")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));
        cmd.Parameters.Add(new SqlParameter("@strProperties", msg.Query("strProperties")));

        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Char, 1);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();
        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());
        return msg.GetXmlStr;
    }

    public string ImportFilm(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();
        PccMsg msg = new PccMsg(strXML);

        SqlCommand cmd = new SqlCommand("ImportFilm", Conn);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add(new SqlParameter("@FilmNo", msg.Query("FilmNo")));
        cmd.Parameters.Add(new SqlParameter("@CatNm", msg.Query("CatNm")));
        cmd.Parameters.Add(new SqlParameter("@FilmEng", msg.Query("FilmEng")));
        cmd.Parameters.Add(new SqlParameter("@FilmVnd", msg.Query("FilmVnd")));
        cmd.Parameters.Add(new SqlParameter("@FilmYear", msg.Query("FilmYear")));
        cmd.Parameters.Add(new SqlParameter("@ImgURL", msg.Query("ImgURL")));
        cmd.Parameters.Add(new SqlParameter("@Hero", msg.Query("Hero")));
        cmd.Parameters.Add(new SqlParameter("@Director", msg.Query("Director")));
        cmd.Parameters.Add(new SqlParameter("@National", msg.Query("National")));
        cmd.Parameters.Add(new SqlParameter("@Sound", msg.Query("Sound")));
        cmd.Parameters.Add(new SqlParameter("@Subtitles", msg.Query("Subtitles")));
        cmd.Parameters.Add(new SqlParameter("@Capacity", msg.Query("Capacity")));
        cmd.Parameters.Add(new SqlParameter("@Format", msg.Query("Format")));
        cmd.Parameters.Add(new SqlParameter("@Content", msg.Query("Content")));
        cmd.Parameters.Add(new SqlParameter("@UserID", msg.Query("UserID")));

        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int, 1);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();
        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());
        return msg.GetXmlStr;
    }
    public string Ins_Topic(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_Topic", Conn);
        cmd.CommandType = CommandType.StoredProcedure;


        cmd.Parameters.Add(new SqlParameter("@TopicName", msg.Query("TopicName")));
        cmd.Parameters.Add(new SqlParameter("@ShowMK", msg.Query("ShowMK")));
        cmd.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));


        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }


    public string Ins_Upd_FlowOrderHist(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_Upd_FlowOrderHist", Conn);
        cmd.CommandType = CommandType.StoredProcedure;


        cmd.Parameters.Add(new SqlParameter("@OrderID", msg.Query("OrderID")));
        cmd.Parameters.Add(new SqlParameter("@SignUser", msg.Query("SignUser")));
        cmd.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        cmd.Parameters.Add(new SqlParameter("@Note", msg.Query("Note")));

        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }

    public string Ins_Menu(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_Menu", Conn);
        cmd.CommandType = CommandType.StoredProcedure;


        cmd.Parameters.Add(new SqlParameter("@MenuName", msg.Query("MenuName")));
        cmd.Parameters.Add(new SqlParameter("@MenuURL", msg.Query("MenuURL")));
        cmd.Parameters.Add(new SqlParameter("@LevelMenuID", msg.Query("LevelMenuID")));
        cmd.Parameters.Add(new SqlParameter("@KindNo", msg.Query("KindNo")));
        cmd.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));


        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }
    public string Ins_cat_Properties(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_cat_Properties", Conn);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add(new SqlParameter("@PrtID", msg.Query("PrtID")));
        cmd.Parameters.Add(new SqlParameter("@PrtNm", msg.Query("PrtNm")));
        cmd.Parameters.Add(new SqlParameter("@CatID", msg.Query("CatID")));



        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }
    public string Ins_Catalogue_Properties(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_Catalogue_Properties", Conn);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add(new SqlParameter("@CatID", msg.Query("CatID")));
        cmd.Parameters.Add(new SqlParameter("@TopicID", msg.Query("TopicID")));
        cmd.Parameters.Add(new SqlParameter("@CatName", msg.Query("CatName")));
        cmd.Parameters.Add(new SqlParameter("@strProperties", msg.Query("strProperties")));
        cmd.Parameters.Add(new SqlParameter("@ShowMK", msg.Query("ShowMK")));
        cmd.Parameters.Add(new SqlParameter("@KindNo", msg.Query("KindNo")));
        cmd.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));


        SqlParameter paraCatIDOut = new SqlParameter("@CatIDOut", SqlDbType.Decimal);
        paraCatIDOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraCatIDOut);


        string strOutput = "", strCatIDOut = "";
        int intReturn;


        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);


        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();
        strCatIDOut = paraCatIDOut.Value.ToString();


        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());
        msg.CreateFirstNode("strCatIDOut", strCatIDOut.ToString());

        return msg.GetXmlStr;
    }

    public string Ins_Catalogue(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_Catalogue", Conn);
        cmd.CommandType = CommandType.StoredProcedure;


        cmd.Parameters.Add(new SqlParameter("@TopicID", msg.Query("TopicID")));
        cmd.Parameters.Add(new SqlParameter("@CatName", msg.Query("CatName")));
        cmd.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));


        string strOutput = "", strCatIDOut = "";
        int intReturn;

        SqlParameter paraCatIDOut = new SqlParameter("@CatIDOut", SqlDbType.Decimal);
        paraCatIDOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraCatIDOut);

        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);



        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();
        strCatIDOut = paraCatIDOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());
        msg.CreateFirstNode("strCatIDOut", strCatIDOut.ToString());

        return msg.GetXmlStr;
    }

    public string Ins_Product(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_Product", Conn);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add(new SqlParameter("@PDID", msg.Query("PDID")));
        cmd.Parameters.Add(new SqlParameter("@PdName", msg.Query("PdName")));
        cmd.Parameters.Add(new SqlParameter("@CatID", msg.Query("CatID")));
        cmd.Parameters.Add(new SqlParameter("@Price", msg.Query("Price")));
        cmd.Parameters.Add(new SqlParameter("@Descript", msg.Query("Descript")));
        cmd.Parameters.Add(new SqlParameter("@ImgURL", msg.Query("ImgURL")));
        cmd.Parameters.Add(new SqlParameter("@Unit", msg.Query("Unit")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));
        cmd.Parameters.Add(new SqlParameter("@strProperties", msg.Query("strProperties")));

        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();
        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }
    public string Ins_shr_Authority(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_shr_Authority", Conn);
        cmd.CommandType = CommandType.StoredProcedure;


        cmd.Parameters.Add(new SqlParameter("@AutNm", msg.Query("AutNm")));
        cmd.Parameters.Add(new SqlParameter("@Descript", msg.Query("Descript")));
        cmd.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));


        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();
        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }
    public string Ins_shr_User(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_shr_User", Conn);
        cmd.CommandType = CommandType.StoredProcedure;


        cmd.Parameters.Add(new SqlParameter("@AutID", msg.Query("AutID")));
        cmd.Parameters.Add(new SqlParameter("@CusNm", msg.Query("CusNm")));
        cmd.Parameters.Add(new SqlParameter("@UserNm", msg.Query("UserNm")));
        cmd.Parameters.Add(new SqlParameter("@Password", msg.Query("Password")));
        cmd.Parameters.Add(new SqlParameter("@AccountID", msg.Query("AccountID")));
        cmd.Parameters.Add(new SqlParameter("@TaxNo", msg.Query("TaxNo")));
        cmd.Parameters.Add(new SqlParameter("@Address", msg.Query("Address")));
        cmd.Parameters.Add(new SqlParameter("@PlaceID", msg.Query("PlaceID")));
        cmd.Parameters.Add(new SqlParameter("@BirthDay", msg.Query("BirthDay")));
        cmd.Parameters.Add(new SqlParameter("@Phone", msg.Query("Phone")));
        cmd.Parameters.Add(new SqlParameter("@Sex", msg.Query("Sex")));
        cmd.Parameters.Add(new SqlParameter("@Email", msg.Query("Email")));
        cmd.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        cmd.Parameters.Add(new SqlParameter("@Rate", msg.Query("Rate")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));


        string strOutput = "", strOutUserID = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);

        SqlParameter paraOutUserID = new SqlParameter("@strOutUserID", SqlDbType.Decimal, 12);
        paraOutUserID.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOutUserID);

        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();
        strOutUserID = paraOutUserID.Value.ToString();
        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());
        msg.CreateFirstNode("strOutUserID", strOutUserID.ToString());



        return msg.GetXmlStr;
    }

    public string Ins_OrderPD(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_OrderPD", Conn);
        cmd.CommandType = CommandType.StoredProcedure;


        cmd.Parameters.Add(new SqlParameter("@UserID", msg.Query("UserID")));
        cmd.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        cmd.Parameters.Add(new SqlParameter("@Repaid", msg.Query("Repaid")));
        cmd.Parameters.Add(new SqlParameter("@RemainPrice", msg.Query("RemainPrice")));
        cmd.Parameters.Add(new SqlParameter("@Note", msg.Query("Note")));
        cmd.Parameters.Add(new SqlParameter("@Note_Cus", msg.Query("Note_Cus")));
        cmd.Parameters.Add(new SqlParameter("@USD", msg.Query("USD")));
        cmd.Parameters.Add(new SqlParameter("@Note_MK", msg.Query("Note_MK")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));
        cmd.Parameters.Add(new SqlParameter("@KindNo", msg.Query("KindNo")));



        string strOutput = "", strOrderIDMsg = "";
        int intReturn;
        SqlParameter paraOutOrderIDMsg = new SqlParameter("@OrderIDMsg", SqlDbType.Char, 14);
        paraOutOrderIDMsg.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOutOrderIDMsg);
        SqlParameter paraOutErrMsg = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOutErrMsg.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOutErrMsg);

        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOutErrMsg.Value.ToString();
        strOrderIDMsg = paraOutOrderIDMsg.Value.ToString();
        msg = new PccMsg();
        msg.CreateFirstNode("OrderIDMsg", strOrderIDMsg);
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput);


        return msg.GetXmlStr;
    }

    public string Ins_Upd_Download(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_Upd_Download", Conn);
        cmd.CommandType = CommandType.StoredProcedure;


        cmd.Parameters.Add(new SqlParameter("@IdD", msg.Query("IdD")));
        cmd.Parameters.Add(new SqlParameter("@TitleD", msg.Query("TitleD")));
        cmd.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));


        string strOutput = "", strIdDOut = "";
        int intReturn;

        SqlParameter paraIdDOut = new SqlParameter("@IdDOut", SqlDbType.Decimal);
        paraIdDOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraIdDOut);

        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);



        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();
        strIdDOut = paraIdDOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());
        msg.CreateFirstNode("IdDOut", strIdDOut.ToString());

        return msg.GetXmlStr;
    }

    public string Ins_Upd_DowloadDetail(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);
        SqlCommand cmd = new SqlCommand("Ins_Upd_DowloadDetail", Conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new SqlParameter("@IdD", msg.Query("IdD")));
        cmd.Parameters.Add(new SqlParameter("@Name", msg.Query("Name")));
        cmd.Parameters.Add(new SqlParameter("@Link", msg.Query("Link")));
        cmd.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));
        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();
        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());
        return msg.GetXmlStr;
    }

    public string Ins_Upd_Product_IMG(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);
        SqlCommand cmd = new SqlCommand("Ins_Upd_Product_IMG", Conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new SqlParameter("@ImgPD_ID", msg.Query("ImgPD_ID")));
        cmd.Parameters.Add(new SqlParameter("@PDID", msg.Query("PDID")));
        cmd.Parameters.Add(new SqlParameter("@ImgPD_Url", msg.Query("ImgPD_Url")));
        cmd.Parameters.Add(new SqlParameter("@ImgPD_Desc", msg.Query("ImgPD_Desc")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));
        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();
        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        return msg.GetXmlStr;
    }
    public string Ins_Upd_Rate(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);
        SqlCommand cmd = new SqlCommand("Ins_Upd_Rate", Conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new SqlParameter("@RateId", msg.Query("RateId")));
        cmd.Parameters.Add(new SqlParameter("@RateDate", msg.Query("RateDate")));
        cmd.Parameters.Add(new SqlParameter("@EditMK", msg.Query("EditMK")));
        cmd.Parameters.Add(new SqlParameter("@BankNm", msg.Query("BankNm")));
        cmd.Parameters.Add(new SqlParameter("@USD", msg.Query("USD")));
        cmd.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));
        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();
        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());
        return msg.GetXmlStr;
    }
    public string Ins_Product_Comment(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);
        SqlCommand cmd = new SqlCommand("Ins_Product_Comment", Conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new SqlParameter("@PDID", msg.Query("PDID")));
        cmd.Parameters.Add(new SqlParameter("@CmPD_CusName", msg.Query("CmPD_CusName")));
        cmd.Parameters.Add(new SqlParameter("@CmPD_Title", msg.Query("CmPD_Title")));
        cmd.Parameters.Add(new SqlParameter("@CmPD_Content", msg.Query("CmPD_Content")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));
        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();
        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());
        return msg.GetXmlStr;
    }


    #endregion

    #region "Upd"
    public string Upd_shr_User_Email(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Upd_shr_User_Email", Conn);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add(new SqlParameter("@UserID", msg.Query("UserID")));
        cmd.Parameters.Add(new SqlParameter("@Email", msg.Query("Email")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));


        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }
    public string Upd_shr_User_Password(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Upd_shr_User_Password", Conn);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add(new SqlParameter("@UserID", msg.Query("UserID")));
        cmd.Parameters.Add(new SqlParameter("@Password", msg.Query("Password")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));


        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }
    public string Upd_shr_InfUser(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Upd_shr_InfUser", Conn);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add(new SqlParameter("@UserID", msg.Query("UserID")));
        cmd.Parameters.Add(new SqlParameter("@CusNm", msg.Query("CusNm")));
        cmd.Parameters.Add(new SqlParameter("@Sex", msg.Query("Sex")));
        cmd.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));


        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }

    public string Upd_Topic(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Upd_Topic", Conn);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add(new SqlParameter("@TopicID", msg.Query("TopicID")));
        cmd.Parameters.Add(new SqlParameter("@TopicName", msg.Query("TopicName")));
        cmd.Parameters.Add(new SqlParameter("@ShowMK", msg.Query("ShowMK")));
        cmd.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));


        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }

    public string Upd_Menu(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Upd_Menu", Conn);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add(new SqlParameter("@MenuID", msg.Query("MenuID")));
        cmd.Parameters.Add(new SqlParameter("@MenuName", msg.Query("MenuName")));
        cmd.Parameters.Add(new SqlParameter("@MenuURL", msg.Query("MenuURL")));
        cmd.Parameters.Add(new SqlParameter("@LevelMenuID", msg.Query("LevelMenuID")));
        cmd.Parameters.Add(new SqlParameter("@KindNo", msg.Query("KindNo")));
        cmd.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));


        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }
    public string Upd_Catalogue(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Upd_Catalogue", Conn);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add(new SqlParameter("@CatID", msg.Query("CatID")));
        cmd.Parameters.Add(new SqlParameter("@TopicID", msg.Query("TopicID")));
        cmd.Parameters.Add(new SqlParameter("@CatName", msg.Query("CatName")));
        cmd.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));


        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }

    public string Upd_SeqMenu(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Upd_SeqMenu", Conn);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add(new SqlParameter("@MenuID1", msg.Query("MenuID1")));
        cmd.Parameters.Add(new SqlParameter("@MenuID2", msg.Query("MenuID2")));



        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }

    public string Upd_SeqTopic(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Upd_SeqTopic", Conn);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add(new SqlParameter("@ID1", msg.Query("ID1")));
        cmd.Parameters.Add(new SqlParameter("@ID2", msg.Query("ID2")));



        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }

    public string Upd_shr_Authority(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Upd_shr_Authority", Conn);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add(new SqlParameter("@AutID", msg.Query("AutID")));
        cmd.Parameters.Add(new SqlParameter("@AutNm", msg.Query("AutNm")));
        cmd.Parameters.Add(new SqlParameter("@Descript", msg.Query("Descript")));
        cmd.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));


        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();
        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }
    public string Upd_shr_User(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Upd_shr_User", Conn);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add(new SqlParameter("@UserID", msg.Query("UserID")));
        cmd.Parameters.Add(new SqlParameter("@AutID", msg.Query("AutID")));
        cmd.Parameters.Add(new SqlParameter("@CusNm", msg.Query("CusNm")));
        cmd.Parameters.Add(new SqlParameter("@UserNm", msg.Query("UserNm")));
        cmd.Parameters.Add(new SqlParameter("@Password", msg.Query("Password")));
        cmd.Parameters.Add(new SqlParameter("@AccountID", msg.Query("AccountID")));
        cmd.Parameters.Add(new SqlParameter("@Address", msg.Query("Address")));
        cmd.Parameters.Add(new SqlParameter("@PlaceID", msg.Query("PlaceID")));
        cmd.Parameters.Add(new SqlParameter("@BirthDay", msg.Query("BirthDay")));
        cmd.Parameters.Add(new SqlParameter("@Phone", msg.Query("Phone")));
        cmd.Parameters.Add(new SqlParameter("@Sex", msg.Query("Sex")));
        cmd.Parameters.Add(new SqlParameter("@Email", msg.Query("Email")));
        cmd.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        cmd.Parameters.Add(new SqlParameter("@Rate", msg.Query("Rate")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));


        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();
        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }

    public string Upd_shr_UserOrder(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Upd_shr_UserOrder", Conn);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add(new SqlParameter("@UserID", msg.Query("UserID")));
        cmd.Parameters.Add(new SqlParameter("@AutID", msg.Query("AutID")));
        cmd.Parameters.Add(new SqlParameter("@CusNm", msg.Query("CusNm")));
        cmd.Parameters.Add(new SqlParameter("@AccountID", msg.Query("AccountID")));
        cmd.Parameters.Add(new SqlParameter("@Address", msg.Query("Address")));
        cmd.Parameters.Add(new SqlParameter("@PlaceID", msg.Query("PlaceID")));
        cmd.Parameters.Add(new SqlParameter("@Phone", msg.Query("Phone")));
        cmd.Parameters.Add(new SqlParameter("@Email", msg.Query("Email")));
        cmd.Parameters.Add(new SqlParameter("@TaxNo", msg.Query("TaxNo")));

        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();
        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }
    public string Upd_Product(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Upd_Product", Conn);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add(new SqlParameter("@PdID", msg.Query("PdID")));
        cmd.Parameters.Add(new SqlParameter("@PdName", msg.Query("PdName")));
        cmd.Parameters.Add(new SqlParameter("@CatID", msg.Query("CatID")));
        cmd.Parameters.Add(new SqlParameter("@Price", msg.Query("Price")));
        cmd.Parameters.Add(new SqlParameter("@Descript", msg.Query("Descript")));
        cmd.Parameters.Add(new SqlParameter("@ImgURL", msg.Query("ImgURL")));
        cmd.Parameters.Add(new SqlParameter("@Quantity", msg.Query("Quantity")));
        cmd.Parameters.Add(new SqlParameter("@Unit", msg.Query("Unit")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));


        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();
        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }

    public string Upd_OriginalPrice(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Upd_OriginalPrice", Conn);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add(new SqlParameter("@SPdID", msg.Query("SPdID")));
        cmd.Parameters.Add(new SqlParameter("@PdID", msg.Query("PDID")));
        cmd.Parameters.Add(new SqlParameter("@OriginalPrice", msg.Query("OriginalPrice")));
        cmd.Parameters.Add(new SqlParameter("@OriginalRate", msg.Query("OriginalRate")));
        cmd.Parameters.Add(new SqlParameter("@OriginalDate", msg.Query("OriginalDate")));


        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();
        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }

    #endregion

    #region "Del"
    public string Del_News(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Del_News", Conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new SqlParameter("@NewsID", msg.Query("NewsID")));
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        string strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }
    public string Del_Topic(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Del_Topic", Conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new SqlParameter("@TopicID", msg.Query("TopicID")));
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        string strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }

    public string Del_Menu(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Del_Menu", Conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new SqlParameter("@MenuID", msg.Query("MenuID")));
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        string strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }

    public string Del_Catalogue(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Del_Catalogue", Conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new SqlParameter("@CatID", msg.Query("CatID")));
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        string strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }

    public string Del_Product(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Del_Product", Conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new SqlParameter("@PdID", msg.Query("PdID")));
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        string strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }

    public string Del_shr_Authority(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Del_shr_Authority", Conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new SqlParameter("@AutID", msg.Query("AutID")));
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        string strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }
    public string Del_shr_User(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Del_shr_User", Conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new SqlParameter("@UserID", msg.Query("UserID")));
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        string strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }
    #endregion

    #region "Ins_Upd"

    public string Ins_Upd_StoreDetail(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_Upd_StoreDetail", Conn);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add(new SqlParameter("@StDID", msg.Query("StDID")));
        cmd.Parameters.Add(new SqlParameter("@StM", msg.Query("StM")));
        cmd.Parameters.Add(new SqlParameter("@PDID", msg.Query("PDID")));
        cmd.Parameters.Add(new SqlParameter("@StID", msg.Query("StID")));
        cmd.Parameters.Add(new SqlParameter("@Unit", msg.Query("Unit")));
        cmd.Parameters.Add(new SqlParameter("@InputPrice", msg.Query("InputPrice")));
        cmd.Parameters.Add(new SqlParameter("@InputRate", msg.Query("InputRate")));
        cmd.Parameters.Add(new SqlParameter("@Quantity", msg.Query("Quantity")));
        cmd.Parameters.Add(new SqlParameter("@Total", msg.Query("Total")));
        cmd.Parameters.Add(new SqlParameter("@UserID", msg.Query("UserID")));


        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }

    public string Ins_Upd_StoreMain(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_Upd_StoreMain", Conn);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add(new SqlParameter("@StM", msg.Query("StM")));
        cmd.Parameters.Add(new SqlParameter("@DisCompID", msg.Query("DisCompID")));
        cmd.Parameters.Add(new SqlParameter("@InputDate", msg.Query("InputDate")));
        cmd.Parameters.Add(new SqlParameter("@USD", msg.Query("USD")));
        cmd.Parameters.Add(new SqlParameter("@UserID", msg.Query("UserID")));

        string strOutput = "", StMOut = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);

        SqlParameter paraStMOut = new SqlParameter("@StMOut", SqlDbType.Decimal, 12);
        paraStMOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraStMOut);

        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();
        StMOut = paraStMOut.Value.ToString();
        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());
        msg.CreateFirstNode("strStMOut", StMOut.ToString());


        return msg.GetXmlStr;
    }



    public string Ins_Upd_shr_User(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_Upd_shr_User", Conn);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add(new SqlParameter("@UserID", msg.Query("UserID")));
        cmd.Parameters.Add(new SqlParameter("@AutID", msg.Query("AutID")));
        cmd.Parameters.Add(new SqlParameter("@CusNm", msg.Query("CusNm")));
        cmd.Parameters.Add(new SqlParameter("@UserNm", msg.Query("UserNm")));
        cmd.Parameters.Add(new SqlParameter("@Password", msg.Query("Password")));
        cmd.Parameters.Add(new SqlParameter("@AccountID", msg.Query("AccountID")));
        cmd.Parameters.Add(new SqlParameter("@Address", msg.Query("Address")));
        cmd.Parameters.Add(new SqlParameter("@PlaceID", msg.Query("PlaceID")));
        cmd.Parameters.Add(new SqlParameter("@BirthDay", msg.Query("BirthDay")));
        cmd.Parameters.Add(new SqlParameter("@Phone", msg.Query("Phone")));
        cmd.Parameters.Add(new SqlParameter("@Sex", msg.Query("Sex")));
        cmd.Parameters.Add(new SqlParameter("@TaxNo", msg.Query("TaxNo")));
        cmd.Parameters.Add(new SqlParameter("@Email", msg.Query("Email")));
        cmd.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        cmd.Parameters.Add(new SqlParameter("@Rate", msg.Query("Rate")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));


        string strOutput = "", strOutUserID = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);

        SqlParameter paraOutUserID = new SqlParameter("@strOutUserID", SqlDbType.Decimal, 12);
        paraOutUserID.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOutUserID);

        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();
        strOutUserID = paraOutUserID.Value.ToString();
        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());
        msg.CreateFirstNode("strOutUserID", strOutUserID.ToString());


        return msg.GetXmlStr;
    }
    public string Ins_Upd_Menud(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_Upd_Menud", Conn);
        cmd.CommandType = CommandType.StoredProcedure;

        //  cmd.Parameters.Add(new SqlParameter("@Menud_ID", msg.Query("Menud_ID")));
        cmd.Parameters.Add(new SqlParameter("@MenuID", msg.Query("MenuID")));
        cmd.Parameters.Add(new SqlParameter("@UserID", msg.Query("UserID")));
        cmd.Parameters.Add(new SqlParameter("@AutID", msg.Query("AutID")));
        cmd.Parameters.Add(new SqlParameter("@show_mk", msg.Query("show_mk")));
        cmd.Parameters.Add(new SqlParameter("@add_mk", msg.Query("add_mk")));
        cmd.Parameters.Add(new SqlParameter("@upd_mk", msg.Query("upd_mk")));
        cmd.Parameters.Add(new SqlParameter("@del_mk", msg.Query("del_mk")));
        cmd.Parameters.Add(new SqlParameter("@rpt_mk", msg.Query("rpt_mk")));
        cmd.Parameters.Add(new SqlParameter("@send_mk", msg.Query("send_mk")));
        cmd.Parameters.Add(new SqlParameter("@sign_mk", msg.Query("sign_mk")));


        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }
    public string Ins_Upd_News(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_Upd_News", Conn);
        cmd.CommandType = CommandType.StoredProcedure;


        cmd.Parameters.Add(new SqlParameter("@NewsID", msg.Query("NewsID")));
        cmd.Parameters.Add(new SqlParameter("@Title", msg.Query("Title")));
        cmd.Parameters.Add(new SqlParameter("@Content", msg.Query("Content")));
        cmd.Parameters.Add(new SqlParameter("@ImgURL", msg.Query("ImgURL")));
        cmd.Parameters.Add(new SqlParameter("@KindNo", msg.Query("KindNo")));
        cmd.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));


        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }

    public string Ins_Store_Product(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_Store_Product", Conn);
        cmd.CommandType = CommandType.StoredProcedure;


        cmd.Parameters.Add(new SqlParameter("@PdID", msg.Query("PDID")));
        cmd.Parameters.Add(new SqlParameter("@StID", msg.Query("StID")));
        cmd.Parameters.Add(new SqlParameter("@Input", msg.Query("Input")));
        cmd.Parameters.Add(new SqlParameter("@Output", msg.Query("Output")));

        cmd.Parameters.Add(new SqlParameter("@OriginalPrice", msg.Query("OriginalPrice")));
        cmd.Parameters.Add(new SqlParameter("@OriginalRate", msg.Query("OriginalRate")));
        cmd.Parameters.Add(new SqlParameter("@OriginalDate", msg.Query("OriginalDate")));

        cmd.Parameters.Add(new SqlParameter("@OrderID", msg.Query("OrderID")));
        cmd.Parameters.Add(new SqlParameter("@Note", msg.Query("Note")));
        cmd.Parameters.Add(new SqlParameter("@Note_MK", msg.Query("Note_MK")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));
        cmd.Parameters.Add(new SqlParameter("@flag", msg.Query("flag")));



        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }

    public string Ins_Upd_Banner(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_Upd_Banner", Conn);
        cmd.CommandType = CommandType.StoredProcedure;


        cmd.Parameters.Add(new SqlParameter("@ID", msg.Query("ID")));
        cmd.Parameters.Add(new SqlParameter("@Title", msg.Query("Title")));
        cmd.Parameters.Add(new SqlParameter("@Content", msg.Query("Content")));
        cmd.Parameters.Add(new SqlParameter("@ImgURL", msg.Query("ImgURL")));
        cmd.Parameters.Add(new SqlParameter("@NavigateUrl", msg.Query("NavigateUrl")));
        cmd.Parameters.Add(new SqlParameter("@ShowMK", msg.Query("ShowMK")));
        cmd.Parameters.Add(new SqlParameter("@BannerType", msg.Query("BannerType")));
        cmd.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));



        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }



    public string Ins_Upd_Ads(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_Upd_Ads", Conn);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add(new SqlParameter("@AdsID", msg.Query("AdsID")));
        cmd.Parameters.Add(new SqlParameter("@KindNo", msg.Query("KindNo")));
        cmd.Parameters.Add(new SqlParameter("@AdsNm", msg.Query("AdsNm")));
        cmd.Parameters.Add(new SqlParameter("@AdsDes", msg.Query("AdsDes")));
        cmd.Parameters.Add(new SqlParameter("@AdsLink", msg.Query("AdsLink")));
        cmd.Parameters.Add(new SqlParameter("@AdsURL", msg.Query("AdsURL")));
        cmd.Parameters.Add(new SqlParameter("@AdsType", msg.Query("AdsType")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));



        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }


    public string Ins_Upd_Contact(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_Upd_Contact", Conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new SqlParameter("@KindNo", msg.Query("KindNo")));
        cmd.Parameters.Add(new SqlParameter("@Content", msg.Query("Content")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));

        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }


    public string Ins_Upd_DistributionCompany(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_Upd_DistributionCompany", Conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new SqlParameter("@DisCompID", msg.Query("DisCompID")));
        cmd.Parameters.Add(new SqlParameter("@Name", msg.Query("Name")));
        cmd.Parameters.Add(new SqlParameter("@Address", msg.Query("Address")));
        cmd.Parameters.Add(new SqlParameter("@TaxNo", msg.Query("TaxNo")));
        cmd.Parameters.Add(new SqlParameter("@Phone", msg.Query("Phone")));
        cmd.Parameters.Add(new SqlParameter("@Email", msg.Query("Email")));
        cmd.Parameters.Add(new SqlParameter("@Note", msg.Query("Note")));
        cmd.Parameters.Add(new SqlParameter("@UserID", msg.Query("UserID")));

        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }

    public string Upd_SignPD(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Upd_SignPD", Conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new SqlParameter("@OrderID", msg.Query("OrderID")));
        cmd.Parameters.Add(new SqlParameter("@flag", msg.Query("flag")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));

        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }

    public string Upd_WaitingSignOrderPD(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Upd_WaitingSignOrderPD", Conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new SqlParameter("@OrderID", msg.Query("OrderID")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));

        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }

    public string Upd_EndOrderPD(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Upd_EndOrderPD", Conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new SqlParameter("@OrderID", msg.Query("OrderID")));
        cmd.Parameters.Add(new SqlParameter("@Repaid", msg.Query("Repaid")));
        cmd.Parameters.Add(new SqlParameter("@RemainPrice", msg.Query("RemainPrice")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));

        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }
    public string Upd_SendOrderPD(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Upd_SendOrderPD", Conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new SqlParameter("@OrderID", msg.Query("OrderID")));
        cmd.Parameters.Add(new SqlParameter("@Repaid", msg.Query("Repaid")));
        cmd.Parameters.Add(new SqlParameter("@RemainPrice", msg.Query("RemainPrice")));
        cmd.Parameters.Add(new SqlParameter("@Note", msg.Query("Note")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));

        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }
    public string Upd_EndOrder_Store(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Upd_EndOrder_Store", Conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new SqlParameter("@OrderID", msg.Query("OrderID")));
        cmd.Parameters.Add(new SqlParameter("@PDID", msg.Query("PDID")));
        cmd.Parameters.Add(new SqlParameter("@StID", msg.Query("StID")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));

        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }
    public string Upd_SendOrderDetail(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Upd_SendOrderDetail", Conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new SqlParameter("@OrderID", msg.Query("OrderID")));
        cmd.Parameters.Add(new SqlParameter("@PDID", msg.Query("PDID")));
        cmd.Parameters.Add(new SqlParameter("@StId", msg.Query("StId")));
        cmd.Parameters.Add(new SqlParameter("@Price", msg.Query("Price")));
        cmd.Parameters.Add(new SqlParameter("@OldPrice", msg.Query("OldPrice")));
        cmd.Parameters.Add(new SqlParameter("@Total", msg.Query("Total")));
        cmd.Parameters.Add(new SqlParameter("@NoteDetail", msg.Query("NoteDetail")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));

        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }
    public string Ins_SendOrderDetail(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_SendOrderDetail", Conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new SqlParameter("@OrderID", msg.Query("OrderID")));
        cmd.Parameters.Add(new SqlParameter("@PDID", msg.Query("PDID")));
        cmd.Parameters.Add(new SqlParameter("@StId", msg.Query("StId")));
        cmd.Parameters.Add(new SqlParameter("@Rate", msg.Query("Rate")));
        cmd.Parameters.Add(new SqlParameter("@Quantity", msg.Query("Quantity")));
        cmd.Parameters.Add(new SqlParameter("@Price", msg.Query("Price")));
        cmd.Parameters.Add(new SqlParameter("@OldPrice", msg.Query("OldPrice")));
        cmd.Parameters.Add(new SqlParameter("@Total", msg.Query("Total")));
        cmd.Parameters.Add(new SqlParameter("@OldTotal", msg.Query("OldTotal")));
        cmd.Parameters.Add(new SqlParameter("@NoteDetail", msg.Query("NoteDetail")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));

        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }
    public string Ins_Upd_Rss(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_Upd_Rss", Conn);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add(new SqlParameter("@RssId", msg.Query("RssId")));
        cmd.Parameters.Add(new SqlParameter("@Title", msg.Query("Title")));
        cmd.Parameters.Add(new SqlParameter("@Link", msg.Query("Link")));
        cmd.Parameters.Add(new SqlParameter("@ShowMK", msg.Query("ShowMK")));
        cmd.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));

        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }

    public string Ins_Upd_Product(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_Upd_Product", Conn);
        cmd.CommandType = CommandType.StoredProcedure;


        cmd.Parameters.Add(new SqlParameter("@PDID", msg.Query("PDID")));
        cmd.Parameters.Add(new SqlParameter("@PdName", msg.Query("PdName")));
        cmd.Parameters.Add(new SqlParameter("@CatID", msg.Query("CatID")));
        cmd.Parameters.Add(new SqlParameter("@Price", msg.Query("Price")));
        cmd.Parameters.Add(new SqlParameter("@Rate", msg.Query("Rate")));

        cmd.Parameters.Add(new SqlParameter("@IsSaleOf", msg.Query("IsSaleOf")));
        cmd.Parameters.Add(new SqlParameter("@DiscountPrice", msg.Query("DiscountPrice")));
        cmd.Parameters.Add(new SqlParameter("@DiscountRate", msg.Query("DiscountRate")));

        cmd.Parameters.Add(new SqlParameter("@Warranty", msg.Query("Warranty")));
        cmd.Parameters.Add(new SqlParameter("@Descript", msg.Query("Descript")));
        cmd.Parameters.Add(new SqlParameter("@ImgURL", msg.Query("ImgURL")));
        cmd.Parameters.Add(new SqlParameter("@Unit", msg.Query("Unit")));
        cmd.Parameters.Add(new SqlParameter("@IsHot", msg.Query("IsHot")));
        cmd.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        cmd.Parameters.Add(new SqlParameter("@Capacity", msg.Query("Capacity")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));
        cmd.Parameters.Add(new SqlParameter("@strProperties", msg.Query("strProperties")));

        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();
        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }


    public string Ins_Upd_Film(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_Upd_Film", Conn);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add(new SqlParameter("@FilmID", msg.Query("FilmID")));
        cmd.Parameters.Add(new SqlParameter("@FilmNo", msg.Query("FilmNo")));
        cmd.Parameters.Add(new SqlParameter("@CatID", msg.Query("CatID")));
        cmd.Parameters.Add(new SqlParameter("@FilmEng", msg.Query("FilmEng")));
        cmd.Parameters.Add(new SqlParameter("@FilmVnd", msg.Query("FilmVnd")));
        cmd.Parameters.Add(new SqlParameter("@FilmYear", msg.Query("FilmYear")));
        cmd.Parameters.Add(new SqlParameter("@ImgURL", msg.Query("ImgURL")));
        cmd.Parameters.Add(new SqlParameter("@Hero", msg.Query("Hero")));
        cmd.Parameters.Add(new SqlParameter("@Director", msg.Query("Director")));
        cmd.Parameters.Add(new SqlParameter("@National", msg.Query("National")));
        cmd.Parameters.Add(new SqlParameter("@Sound", msg.Query("Sound")));
        cmd.Parameters.Add(new SqlParameter("@Subtitles", msg.Query("Subtitles")));
        cmd.Parameters.Add(new SqlParameter("@Capacity", msg.Query("Capacity")));
        cmd.Parameters.Add(new SqlParameter("@Format", msg.Query("Format")));
        cmd.Parameters.Add(new SqlParameter("@Content", msg.Query("Content")));
        cmd.Parameters.Add(new SqlParameter("@IsHot", msg.Query("IsHot")));
        cmd.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        cmd.Parameters.Add(new SqlParameter("@UserID", msg.Query("UserID")));

        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();
        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }


    public string Ins_Upd_OnlineSurport(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_Upd_OnlineSurport", Conn);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add(new SqlParameter("@OnlineID", msg.Query("OnlineID")));
        cmd.Parameters.Add(new SqlParameter("@OnlineName", msg.Query("OnlineName")));
        cmd.Parameters.Add(new SqlParameter("@NickName", msg.Query("NickName")));
        cmd.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));

        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }

    public string Ins_Upd_Store(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_Upd_Store", Conn);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add(new SqlParameter("@StID", msg.Query("StID")));
        cmd.Parameters.Add(new SqlParameter("@StName", msg.Query("StName")));
        cmd.Parameters.Add(new SqlParameter("@St_Desc", msg.Query("St_Desc")));
        cmd.Parameters.Add(new SqlParameter("@Status", msg.Query("Status")));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));

        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }

    public string Ins_Upd_shr_UserSign(string strXML, byte[] bFile)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_Upd_shr_UserSign", Conn);
        cmd.CommandType = CommandType.StoredProcedure;


        cmd.Parameters.Add(new SqlParameter("@UserID", msg.Query("UserID")));
        cmd.Parameters.Add(new SqlParameter("@Ext_no", msg.Query("Ext_no")));
        cmd.Parameters.Add(new SqlParameter("@Sign_pic", bFile));
        cmd.Parameters.Add(new SqlParameter("@UpdID", msg.Query("UpdID")));

        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }
    public string Ins_Upd_shr_AutUser(string strXML)
    {

        if (Conn.State == ConnectionState.Closed)
            Conn.Open();

        PccMsg msg = new PccMsg(strXML);


        SqlCommand cmd = new SqlCommand("Ins_Upd_shr_AutUser", Conn);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add(new SqlParameter("@UserID", msg.Query("UserID")));
        cmd.Parameters.Add(new SqlParameter("@Sign_mk", msg.Query("Sign_mk")));
        cmd.Parameters.Add(new SqlParameter("@Print_mk", msg.Query("Print_mk")));
        cmd.Parameters.Add(new SqlParameter("@Review_mk", msg.Query("Review_mk")));

        string strOutput = "";
        int intReturn;
        SqlParameter paraOut = new SqlParameter("@ErrMsg", SqlDbType.Int);
        paraOut.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(paraOut);
        intReturn = cmd.ExecuteNonQuery();
        strOutput = paraOut.Value.ToString();

        msg = new PccMsg();
        msg.CreateFirstNode("intReturn", intReturn.ToString());
        msg.CreateFirstNode("strOutput", strOutput.ToString());


        return msg.GetXmlStr;
    }

    #endregion

    #region "Common"
    public string killSQLInjectionLogin(string sInput)
    {
        string newChars = sInput;
        if (newChars != "" && newChars != null)
        {
            string[] badChars = { "select", "drop", ";", "--", "insert", "delete", "xp_", "update", "shutdown", "having", "xp_regwrite", "xp_regdeletevalue", "xp_cmdshell", "'" };

            for (int i = 0; i < badChars.Length; i++)
            {
                if (newChars.ToLower().IndexOf(badChars[i]) != -1)
                    newChars = "";
            }
        }
        return newChars;
    }

    public string killSQLInjection(string sInput)
    {
        string newChars = sInput;
        if (newChars != "" && newChars != null)
        {
            string[] badChars = { "select", "drop", ";", "--", "insert", "delete", "xp_", "update", "shutdown", "having", "xp_regwrite", "xp_regdeletevalue", "xp_cmdshell", "'" };

            for (int i = 0; i < badChars.Length; i++)
            {
                newChars = newChars.ToLower().Replace(badChars[i], "");
            }
        }
        return newChars;
    }
    #endregion
}
